package io.shuttle.mbe.api

import io.shuttle.mbe.api.annotation.ChromeMinVersion
import io.shuttle.mbe.api.annotation.ChromeOSOnly
import io.shuttle.mbe.api.annotation.PromiseStyleMinVersion
import io.shuttle.mbe.api.types.Value1Function
import io.shuttle.mbe.core.Promise

////////////////////
// LoginState
////////////////////
/**
 * Use the `Browser.loginState` API to read and monitor the login state.
 *
 * Permissions: "loginState"
 * @platform ChromeOS only
 * @since Chrome 78
 */
@ChromeMinVersion(78)
@ChromeOSOnly
interface LoginState {
    // Gets the type of the profile the extension is in.
    @PromiseStyleMinVersion(96)
     fun getProfileType(
        callback: Value1Function<ProfileType>? = null
    ): Promise<ProfileType>

    // Gets the current session state.
    @PromiseStyleMinVersion(96)
     fun getSessionState(
        callback: Value1Function<SessionState>? = null
    ): Promise<SessionState>

    // Dispatched when the session state changes. sessionState is the new session state.
     val onSessionStateChanged: Events.Event<Value1Function<SessionState>>

    enum class ProfileType {
        // Specifies that the extension is in the signin profile.
        SIGNIN_PROFILE,

        // Specifies that the extension is in the user profile.
        USER_PROFILE
    }

    enum class SessionState {
        // Specifies that the session state is unknown.
        UNKNOWN,

        // Specifies that the user is in the out-of-box-experience screen.
        IN_OOBE_SCREEN,

        // Specifies that the user is in the login screen.
        IN_LOGIN_SCREEN,

        // Specifies that the user is in the session.
        IN_SESSION,

        // Specifies that the user is in the lock screen.
        IN_LOCK_SCREEN,

        // Specifies that the device is in RMA mode, finalizing repairs.
        IN_RMA_SCREEN
    }
}